<?php
session_start();
  include('../include/db_connect.php');

function inDB(){
$password = md5($_SERVER['PHP_AUTH_PW']);
$queryL="SELECT idUSERNAME, gebruikers_naam, wachtwoord FROM USERNAME
                  WHERE BINARY gebruikers_naam='".$_SERVER['PHP_AUTH_USER']."'
                  AND
                  wachtwoord='".$password."'
                  AND
                  admin = 1
                  AND
                  status='act'";
$resL=   mysql_query($queryL) or die(mysql_error());
$usR =   mysql_fetch_array($resL);
if ($usR===false) return false;
return $usR['idUSERNAME'];
}
$usR = inDB();


?>
<style type="text/css">
div#noPermission{
margin-left:auto;
margin-right:auto;
text-align:center;
}
#noPermission a{
text-decoration:none;
color: #000000;
}
#noPermission a:hover{
text-decoration:none;
color: #ff0000;
}
#noPermissionImage a{
margin-top:-30px;
margin-left:auto;
margin-right:auto;
background-image:url('images_admin/icon_stop.png');
display:block;
width:512px;
height:512px;
text-decoration:none;
color: #000000;
}
#noPermissionImage a:hover{
margin-top:-30px;
margin-left:auto;
margin-right:auto;
background-image:url('images_admin/icon_stop2.png');
display:block;
width:512px;
height:512px;
text-decoration:none;
color: #ff0000;
}

</style>
<?php
if(!isset($_SERVER['PHP_AUTH_USER'])||$usR===false)
  {
    Header("WWW-Authenticate: Basic realm=\"Vul je gebruikersnaam en wachtwoord in\"");
    Header("HTTP/1.0 401 Unauthorized");
    echo '<div id="noPermission">';
	echo '<h1> U heeft geen authorisatie om hier te komen.</h1><br>';
	echo '<div id="noPermissionImage">';
	echo '<a href="../index.php"></a>';
	echo '</div>';
	echo '<h1> <a href="../index.php">Klik hierom terug te gaan naar de index site</a> </h1><br>';
	echo '</div>';

   }
else
  {

?>
	<!-- Start of Page Header -->
		
	<?php include("include/admin_header.php"); ?>


		<!-- End of Page Header -->
	<?php include("include/admin_menu.php"); ?>
	<?php echo '<div id="welkomAdmin">';
			$queryL="SELECT USER_DATA.voornaam,USER_DATA.tussenvoegsel, USER_DATA.achternaam FROM USERNAME,USER_DATA
                  WHERE
                  USERNAME.idUSERNAME = USER_DATA.idUSER_DATA
                  AND
                  USERNAME.gebruikers_naam='".$_SERVER['PHP_AUTH_USER']."'
                  AND
                  USERNAME.admin = 1";
                  $resL=   mysql_query($queryL) or die(mysql_error());
                  $row =   mysql_fetch_array($resL);
                  $voornaam = $row['voornaam'];
                  $tussenvoegsel = $row['tussenvoegsel'];
                  $achternaam = $row['achternaam'];
                  

		$productbeheer ='<a href="productbeheer.php">Klik hier om naar productbeheer te gaan</a>';
		$paginabeheer ='<a href="paginabeheer.php">Klik hier om naar paginabeheer te gaan</a>';
		$klantbeheer ='<a href="klantoverzicht.php">Klik hier om naar klantbeheer te gaan</a>';
		$bestellingbeheer ='<a href="orders.php">Klik hier om naar bestellingbeheer te gaan</a>';
		
		$googleanalytics = '<a href="http://www.google.com/intl/nl_ALL/analytics/#utm_source=nl_nl-ha-nl-bk_analytics&amp;utm_medium=ha&amp;utm_campaign=nl&amp;utm_term=google%20analyticsbk_analytics&amp;utm_medium=ha&amp;utm_campaign=nl&amp;utm_term=google%20analyticshttp://www.google.com/intl/nl_ALL/analytics/#utm_source=nl_nl-ha-nl-bk_analytics&amp;utm_medium=ha&amp;utm_campaign=nl&amp;utm_term=google%20analyticsbk_analytics&amp;utm_medium=ha&amp;utm_campaign=nl&amp;utm_term=google%20analytics">
					  Klik hier om naar Google Analytics te gaan</a>';
		echo '<table>';
		echo '<br>';
		echo '<p id="welkomTekst">Welkom '.$voornaam.' '.$tussenvoegsel.' '.$achternaam.'</p>';
		echo '<br>';
		echo '<tr><td><p id="beheerLinks">Beheer</p></td></tr>';
		echo '<tr><td></td><td><p id="beheerLinks">'.$paginabeheer.'</p></td></tr>';
		echo '<tr><td></td><td><p id="beheerLinks">'.$productbeheer.'</p></td></tr>';
		echo '<tr><td></td><td><p id="beheerLinks">'.$klantbeheer.'</p></td></tr>';
		echo '<tr><td></td><td><p id="beheerLinks">'.$bestellingbeheer.'</p></td></tr>';
		echo '<tr><td><p id="beheerLinks">Statistieken</p></td></tr>';
		echo '<tr><td></td><td><p id="beheerLinks">'.$googleanalytics.'</p></td></tr>';
		echo '</table>';
		
		
	echo '</div>'; ?>
	<?php include("include/admin_footer.php"); 
}
?>
